package collection;

import java.util.*;

public class Test {
    public static void main(String[] args) {
        Collection c =new ArrayList();
        c.add(new Point(1,2) );
        c.add(new Point(3,4));
        c.add(new Point(5,6));
        c.add(new Point(7,8));
        c.add(new Point(1,2));
        System.out.println(c);

        Point p=new Point(1,2);
        boolean contains=c.contains(p);
        System.out.println("是否包含:"+contains);


        c.remove(p);
        System.out.println(c);


        Collection cc =new ArrayList();
        Point pp =new Point(1,2);
        cc.add(pp);
        System.out.println("pp:"+pp);
        System.out.println("cc:"+cc);

        pp.setX(200);
        System.out.println("pp:"+pp);
        System.out.println("cc:"+cc);

        Collection c1=new ArrayList();
        c1.add("java");
        c1.add("c++");
        c1.add(".net");
        System.out.println("c1:"+c1);

        Collection c2=new ArrayList();
        c2.add("android");
        c2.add("ios");
        c2.add("java");
        System.out.println("c2:"+c2);

        c1.addAll(c2);
        System.out.println("c1:"+c1);
        System.out.println("c2:"+c2);


        Collection c3= new ArrayList();
        c3.add("c++");
        c3.add("android");
        c3.add("php");
        System.out.println("c3:"+c3);
        boolean containss=c1.containsAll(c3);
        System.out.println("是否包含:"+contains);

        c1.removeAll(c3);
        System.out.println("c1:"+c1);
        System.out.println("c3:"+c3);


        Collection b= new ArrayList();
        b.add("one");
        b.add("*");
        b.add("two");
        b.add("*");
        b.add("three");
        b.add("*");
        b.add("four");
        b.add("*");
        b.add("five");
        System.out.println(b);

        Iterator it=b.iterator();
        while(it.hasNext()){
            String str=(String) it.next();
            System.out.println(str);
            if("*".equals(str)){

                it.remove();

            }
        }
        System.out.println(b);




        String[] array={"one","two","three","four","five"};
        for(int i=0;i<array.length;i++){
            System.out.println(array[i]);

        }
        for(String str: array){
            System.out.println(str);
        }


        Collection aa=new ArrayList();
        aa.add("one");
        aa.add("two");
        aa.add("three");
        aa.add("four");
        aa.add("five");
        Iterator ct = aa.iterator();
        while(ct.hasNext()){
            String str=(String) ct.next();
            System.out.println(str);
        }



        Collection <Point>bb=new ArrayList<>();
        bb.add(new Point(1,2));
        bb.add(new Point(3,4));
        bb.add(new Point(5,6));
        bb.add(new Point(7,8));
        Iterator<Point>tt=c.iterator();
        while(tt.hasNext()){
            Point o=tt.next();
            System.out.println(o);

        }
        for(Point o:bb){
            System.out.println(o);

        }

        Collection<String> q=new ArrayList<>();
        q.add("one");
        q.add("two");
        q.add("three");
        q.add("four");
        q.add("five");
        System.out.println(q);
        String[]arrays=q.toArray(new String[4]);
        System.out.println(Arrays.toString(arrays));


        String[] arrayss = {"one", "two", "three", "four", "five"};
        System.out.println("array:"+ Arrays.toString(array));
        List<String> list = Arrays.asList(arrayss);
        System.out.println("list:"+list);
        array[1] = "six";
        System.out.println("array:"+ Arrays.toString(array));
        System.out.println("list:"+list);
        list.set(2,"seven");
        System.out.println("array:"+ Arrays.toString(array));
        System.out.println("list:"+list);
        list.add("!!!!");

    }
}
